/**
 * 
 */
package org.vidyakiran.app.server.domain.entity;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import org.vidyakiran.app.server.domain.reference.ContactType;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

/**
 * @author Harpreet
 *
 */
@Entity
@MappedSuperclass
public abstract class Contact implements Serializable {

	private static final long serialVersionUID = 5340931859460594836L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Key id;

	@Basic
	protected String contactName;
	
	@Basic
	protected Text contactDescription;
	
	protected ContactType contactType;

	/**
	 * @return the id
	 */
	public Key getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Key id) {
		this.id = id;
	}

	/**
	 * @return the contactName
	 */
	public String getContactName() {
		return contactName;
	}

	/**
	 * @param contactName the contactName to set
	 */
	public void setContactName(String contactName) {
		this.contactName = contactName;
	}

	/**
	 * @return the contactDescription
	 */
	public Text getContactDescription() {
		return contactDescription;
	}

	/**
	 * @param contactDescription the contactDescription to set
	 */
	public void setContactDescription(Text contactDescription) {
		this.contactDescription = contactDescription;
	}

	/**
	 * @return the contactType
	 */
	public ContactType getContactType() {
		return contactType;
	}

	/**
	 * @param contactType the contactType to set
	 */
	public void setContactType(ContactType contactType) {
		this.contactType = contactType;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((contactDescription == null) ? 0 : contactDescription
						.hashCode());
		result = prime * result
				+ ((contactName == null) ? 0 : contactName.hashCode());
		result = prime * result
				+ ((contactType == null) ? 0 : contactType.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Contact other = (Contact) obj;
		if (contactDescription == null) {
			if (other.contactDescription != null)
				return false;
		} else if (!contactDescription.equals(other.contactDescription))
			return false;
		if (contactName == null) {
			if (other.contactName != null)
				return false;
		} else if (!contactName.equals(other.contactName))
			return false;
		if (contactType == null) {
			if (other.contactType != null)
				return false;
		} else if (!contactType.equals(other.contactType))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Contact ["
				+ (contactDescription != null ? "contactDescription="
						+ contactDescription + ", " : "")
				+ (contactName != null ? "contactName=" + contactName + ", "
						: "")
				+ (contactType != null ? "contactType=" + contactType + ", "
						: "") + (id != null ? "id=" + id : "") + "]";
	}

}
